
nums = [4,5,6,7,0,1,2], target = 0


var search = function(nums, target) {
    let left=0;
    let right=nums.length-1;
    while(left<=right)
    {
         if(nums[left]===target)return left
         if(nums[right]===target)return right
         left++
         right--
    }
    return -1
    
};
console.log(search(nums,target));
